<?php
	include("phpxmlrpclib/xmlrpc.inc");
    include("phpxmlrpclib/xmlrpcs.inc");
	
	include("functions.php");
    
    $functionList = array(
			  "getLevel" => array("function" => "getLevel"), 
			  "getScore" => array("function" => "getScore"),
			  "getWorlds" => array("function" => "getWorlds"),
			  "insertScore" => array("function" => "insertScore"),
			  "getLevelCount" => array("function" => "getLevelCount"));

    $s = new xmlrpc_server($functionList, false);

    $s->functions_parameters_type = 'phpvals';
    if (isset($debugXMLRPC) && $debugXMLRPC > 0 && isset($debugXMLRPCFile) && $debugXMLRPCFile != "") 
	  {
		    $s->setDebug($debugXMLRPC);
    }
    $s->service();

    if (isset($debugXMLRPC) && $debugXMLRPC > 0 && isset($debugXMLRPCFile) && $debugXMLRPCFile != "") 
	  {
        $f = fopen($debugXMLRPCFile,"a");
        fwrite($f,"\n----- " . date("Y-m-d H:i:s") . " -----\n");
        $debugInfo = $s->serializeDebug();
        $debugInfo = split("\n",$debugInfo);
        unset($debugInfo[0]);
        unset($debugInfo[count($debugInfo) -1]);
        $debugInfo = join("\n",$debugInfo);	
        fwrite($f,base64_decode($debugInfo));
        fclose($f);
    }

?>
